/**
 * @param {number[]} prices
 * @return {number}
 */
var maxProfit = function(prices) {
  let profit = 0
  let i = 0
  while (i < prices.length) {
    let diff = prices[i + 1] - prices[i]
    if (diff > 0) {
      profit += diff
    }
    i++
  }
  return profit
};